package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constrant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author FCJ
 * @date 2020-01-04 19:44
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {
   @Reference
    private SetmealService setmealService;
    @RequestMapping("/getAllSetmeal")
    public Result getAllSetmeal(){
        try{
            List<Setmeal> setmealList=setmealService.findAll();
            return new Result(true, MessageConstant.QUERY_SETMEALLIST_SUCCESS,setmealList);
        }catch(Exception e){
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);

        }

    }
    @RequestMapping("/finDetaldById")
    public Result finDetaldById(Integer id){
        try{
            Setmeal setmealList=setmealService.finDetaldById(id);
            return new Result(true, MessageConstant.QUERY_SETMEALLIST_SUCCESS,setmealList);
        }catch(Exception e){
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);

        }

    }
    @RequestMapping("/findSetmealById")
    public Result findSetmealById(Integer id){
        try{
            Setmeal setmeal = setmealService.findSetmealById(id);
return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        }catch(Exception e){
       return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }
       }
}
